---
title: CockroachDB
sidebarTitle: CockroachDB
---

This is the implementation of the CockroachDB data handler for MindsDB.

[CockroachDB](https://www.cockroachlabs.com/docs/) was architected for complex, high performant distributed writes and delivers scale-out read capability. CockroachDB delivers simple relational SQL transactions and obscures complexity away from developers. It is wire-compatible with PostgreSQL and provides a familiar and easy interface for developers.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB [locally via Docker](https://docs.mindsdb.com/setup/self-hosted/docker) or use [MindsDB Cloud](https://cloud.mindsdb.com/).
2. To connect CockroachDB to MindsDB, install the required dependencies following [this instruction](/setup/self-hosted/docker#install-dependencies).
3. Install or ensure access to CockroachDB.

## Implementation

CockroachDB is wire-compatible with PostgreSQL. Therefore, its implementation extends the PostgreSQL handler.

The required arguments to establish a connection are as follows:

* `host` is the host name or IP address of the CockroachDB.
* `database` is the name of the database to connect to.
* `user` is the user to authenticate with the CockroachDB.
* `port` is the port to use when connecting.
* `password` is the password to authenticate the user.

In order to make use of this handler and connect to the CockroachDB server in MindsDB, the following syntax can be used:

```sql
CREATE DATABASE cockroachdb
WITH
    engine = 'cockroachdb',
    parameters = {
        "host": "localhost",
        "database": "dbname",
        "user": "admin",
        "password": "password",
        "port": "5432"
    };
```

## Usage

You can use this established connection to query your table as follows:

```sql
SELECT *
FROM cockroachdb.public.db;
```


